# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    # 返回从尾部到头部的列表值序列，例如[1,2,3]
    def printListFromTailToHead(self, listNode):
        List = list()
        
        # 思考:为什么不能用listNode != None and listNode.next != None做判断条件
        # 因为不一定有next（next为空），类似的下标n+1也要考虑清楚有没有
        if listNode != None:
            if listNode.next != None:
                List = self.printListFromTailToHead(listNode.next)
            List.append(listNode.val)
        
        
        return List
        #看错题目了，写了一个冒泡排序
        #curr_1 = listNode;
        #curr_2 = listNode;
        #while curr_1:
        #    while curr_2.next:
        #        if curr_2.val > curr_2.next.val:
        #            temp = curr_2.val
        #            curr_2.val = curr_2.next.val
        #            curr_2.next.val = temp
        #        curr_2 = curr_2.next
        #    curr_1 = curr_1.next
        #
        #curr_3 = listNode;
        #list = []
        #while curr_3:
        #    list.append(curr_3.val)
        #    curr_3 = curr_3.next
        #return list
        
        
        # write code here